package gui.admin.mtm;

import database.TableDatabaseUsage;
import info.UserOrder;

import javax.swing.table.AbstractTableModel;
import java.util.List;

public class FTM extends AbstractTableModel {
    private String[] columnNames={"订单号","身份证号","航班号","航班日期","舱位","折扣","订单状态","订票时间"};
    public List<UserOrder> userOrders= TableDatabaseUsage.getInstance().getRefundOrderList();
    private static FTM instance=new FTM();
    public static FTM getInstance(){return instance;}

    @Override
    public int getRowCount() {
        return userOrders.size();
    }

    @Override
    public int getColumnCount() {
        return columnNames.length;
    }

    @Override
    public Object getValueAt(int rowIndex, int columnIndex) {
        UserOrder dataInfo=userOrders.get(rowIndex);
        if(columnIndex==0){
            return dataInfo.getOrderNO();
        } else if (columnIndex==1) {
            return dataInfo.getIDNO();
        }else if (columnIndex==2){
            return dataInfo.getFlight();
        }else if(columnIndex == 3) {
            return dataInfo.getFdate();
        } else if(columnIndex == 4) {
            return dataInfo.getFclass();
        }else if(columnIndex == 5) {
            return dataInfo.getDiscount();
        } else if(columnIndex == 6) {
            return dataInfo.getOrderState();
        }else if(columnIndex == 7) {
            return dataInfo.getOrderTime();
        }
        return null;
    }
    @Override
    public String getColumnName(int column) {
        return columnNames[column];
    }

    public List<UserOrder> getUserOrders() {
        return userOrders;
    }
}
